//
//  ViewController.m
//  recordTest
//
//  Created by Jason on 2017/5/27.
//  Copyright © 2017年 LiuYu. All rights reserved.
//

#import "ViewController.h"
//#import <Speech/Speech.h>
//#import <AVFoundation/AVFoundation.h>

#import "CameraViewController.h"

#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height


@interface ViewController ()<CAAnimationDelegate>{

    NSCondition *_condition;
    NSThread *mainLoop;

}

//语音
//@property (nonatomic,strong) SFSpeechRecognizer *speechRecognizer;
//@property (nonatomic,strong) AVAudioEngine *audioEngine;
//@property (nonatomic,strong) SFSpeechRecognitionTask *recognitionTask;
@property (weak, nonatomic) IBOutlet UILabel *resultStringLable;
//@property (nonatomic,strong) SFSpeechAudioBufferRecognitionRequest *recognitionRequest;
@property (weak, nonatomic) IBOutlet UIButton *recordButton;


@end


@implementation ViewController

#pragma mark - 控制器视图方法
- (void)viewDidLoad {
    [super viewDidLoad];
    _condition=[[NSCondition alloc] init];
    mainLoop=[[NSThread alloc]initWithTarget:self selector:@selector(run) object:nil];
    [mainLoop setName:@"mainLoop"];
    [mainLoop start];
    

}


////点击任何处，弹出动画
//-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
//{
//    CATransition *shutterAnimation = [CATransition animation];
//    shutterAnimation.delegate = self;
//    shutterAnimation.duration = 1.0f;
//    shutterAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//    shutterAnimation.type = @"cameraIris";
//    shutterAnimation.subtype = @"cameraIris";
//    [self.view.layer addAnimation:shutterAnimation forKey:@"cameraIris"];
//    
//}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];

}

-(void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
}

-(void)dealloc{
   
}
- (IBAction)CameraClick:(UIButton *)sender {
         [self turnTorchOn:YES];
    CameraViewController *cameraView = [[CameraViewController alloc]init];
//    
    [self.navigationController pushViewController:cameraView animated:YES];
}

- (IBAction)startRecordClick:(UIButton *)sender {


}

- (void)turnTorchOn: (bool) on
{

}

#pragma mark - 私有方法

#pragma mark--线程执行方法
-(void)run{
    [_condition lock];
    while (![[NSThread currentThread] isCancelled])
    {
        [self process];
        [NSThread sleepForTimeInterval:1];
    }
    [_condition unlock];
    
}

- (void)process{

    NSLog(@"hahhah");
}


@end
